package com.zhkj.txg.module.product.ui

import android.view.View
import androidx.core.os.bundleOf
import com.zhkj.lib.base.BaseFragment
import com.zhkj.lib.utils.ScreenUtil
import com.zhkj.lib.utils.SpanUtil
import com.zhkj.txg.R
import com.zhkj.txg.module.product.adapter.ShareProductUIEntity
import com.zhkj.txg.utils.ImageUtils
import kotlinx.android.synthetic.main.item_product_share.*

class ProductShareFragment : BaseFragment() {

    companion object {
        private val DATA = "data"
        fun newInstance(data: ShareProductUIEntity): ProductShareFragment = ProductShareFragment().apply {
            arguments = bundleOf(DATA to data)
        }
    }

    override val layoutResId: Int = R.layout.item_product_share

    override fun initUI() {
        (arguments?.getSerializable(DATA) as ShareProductUIEntity).let {
            tvProductTitle.text = it.productName
            tvProductPrice.text = SpanUtil.setMoneySymbol(it.productPrice)
            tvProduct.text = "来自${it.introduce}的推荐"
            ImageUtils.loadRoundCornerImage(
                requireContext(),
                ivProductPic,
                it.productImg,
                ScreenUtil.dip(requireContext(), 10)
            )
            ImageUtils.loadRoundCornerImage(requireContext(), ivProductCode, it.qrCode)
        }
    }

    fun root(): View = root
}